package com.genius.unite_platform.haocai.controller;


import com.alibaba.fastjson.JSONObject;
import com.genius.adminmanager.other.entity.ResponseJson;
import com.genius.unite_platform.haocai.service.HaocaiService;
import com.genius.workflow.log.ControllerLog;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;




@Controller
public class HaocaiSelectController {
	@Autowired
    @Qualifier("haocaiSelectService")
    private HaocaiService haocaiSelectService;
    @RequestMapping("/haocai/tohaocai")
    public String tohaocai(){
        return "/views/unite_platform/haocai/WholeSale";
    }
    
    /**
     * 跳转到列表页面
     */
    @GetMapping("/mobile_page/index2")
    public String shouji_toSelect_toIndex2(){
        return "/views/unite_platform/mobile_page/index2";
    }
    
    
    @GetMapping("/mobile_page/haocai/typd")
    public String typd(){
        return "/views/unite_platform/mobile_page/typd/InventoryGoods";
    }
    
    @GetMapping("/mobile_page/haocai/typd_hc")
    public String typd_hc(){
        return "/views/unite_platform/mobile_page/typd/InventoryGoods_HC";
    }
    
    
    @GetMapping("/mobile_page/haocai/pdsearch")
    public String pdsearch(){
        return "/views/unite_platform/mobile_page/typd/pdsearch";
    }
    @GetMapping("/mobile_page/haocai/pdsearch_hc")
    public String pdsearch_hc(){
        return "/views/unite_platform/mobile_page/typd/pdsearch_HC";
    }
    @GetMapping("/mobile_page/haocai/zcpd")
    public String zcpd(){
        return "/views/unite_platform/mobile_page/typd/zcpd";
    }
    
    
	/**
	 * 全门店盘点 门店数据
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="全门店盘点")
	@PostMapping("/yaohuo/InventoryGoods")
	@ResponseBody
	public JSONObject InventoryGoods(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.InventoryGoods(json, response, session);
		return response;
	}
	
	/**
	 *获取门店
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="获取门店")
	@PostMapping("/yaohuo/getmendian")
	@ResponseBody
	public JSONObject getmendian(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.getmendian(json, response, session);
		return response;
	}
	/**
	 *获取门店
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="获取门店")
	@PostMapping("/yaohuo/getmendian_hc")
	@ResponseBody
	public JSONObject getmendian_hc(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.getmendian_hc(json, response, session);
		return response;
	}
	/**
	 * 盘点开始
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="盘点开始")
	@PostMapping("/typd/pdstart")
	@ResponseBody
	public JSONObject pdstart(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.pdstart(json, response, session);
		return response;
	}
	/**
	 * 盘点开始
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="盘点开始")
	@PostMapping("/typd/pdstart_hc")
	@ResponseBody
	public JSONObject pdstart_hc(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.pdstart_hc(json, response, session);
		return response;
	}
	
	/**
	 * 盘点完成
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="盘点完成")
	@PostMapping("/typd/pdfinish")
	@ResponseBody
	public JSONObject pdfinish(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.pdfinish(json, response, session);
		return response;
	}
	/**
	 * 盘点完成
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="盘点完成")
	@PostMapping("/typd/pdfinish_hc")
	@ResponseBody
	public JSONObject pdfinish_hc(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.pdfinish_hc(json, response, session);
		return response;
	}
	/**
	 * 盘点开始
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="盘点撤销")
	@PostMapping("/typd/pdcancel")
	@ResponseBody
	public JSONObject pdcancel(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.pdcancel(json, response, session);
		return response;
	}
	/**
	 * 盘点开始
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="盘点撤销")
	@PostMapping("/typd/pdcancel_hc")
	@ResponseBody
	public JSONObject pdcancel_hc(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.pdcancel_hc(json, response, session);
		return response;
	}
	/**
	 *InventorySelect  进行中或者已完成门店根据单号查询
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="查询")
	@PostMapping("/typd/InventorySelect")
	@ResponseBody
	public JSONObject InventorySelect(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.InventorySelect(json, response, session);
		return response;
	}
	
	/**
	 *InventorySelect 编辑
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="编辑")
	@PostMapping("/typd/InventoryEdit")
	@ResponseBody
	public JSONObject InventoryEdit(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.InventoryEdit(json, response, session);
		return response;
	}
	
	
	/**
	 *InventorySelect  进行中或者已完成门店根据单号查询
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="查询")
	@PostMapping("/typd/InventorySelect_hc")
	@ResponseBody
	public JSONObject InventorySelect_hc(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.InventorySelect_hc(json, response, session);
		return response;
	}
	

	/**
	 *InventorySelect  编辑
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="编辑")
	@PostMapping("/typd/InventoryEdit_hc")
	@ResponseBody
	public JSONObject InventoryEdit_hc(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.InventoryEdit_hc(json, response, session);
		return response;
	}
	
	/**
	 *InventorySelect  进行中或者已完成门店根据单号查询表头
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="查询标题")
	@PostMapping("/typd/InventoryStoreDiffDtl")
	@ResponseBody
	public JSONObject InventoryStoreDiffDtl(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.InventoryStoreDiffDtl(json, response, session);
		return response;
	}
	/**
	 *InventorySelect  进行中或者已完成门店根据单号查询表头
	 * @param session 
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="查询标题")
	@PostMapping("/typd/InventoryStoreDiffDtl_hc")
	@ResponseBody
	public JSONObject InventoryStoreDiffDtl_hc(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.InventoryStoreDiffDtl_hc(json, response, session);
		return response;
	}
	
	
    @GetMapping("/mobile_page/haocai/mendian")
    public String zcpd(@RequestParam("StoreNO") String StoreNO,@RequestParam("StoreName") String StoreName,@RequestParam("Statue") String Statue,
    					ModelMap map) {
    	map.addAttribute("StoreNO", StoreNO);
    	map.addAttribute("StoreName", StoreName);
    	map.addAttribute("Statue", Statue);
        return "/views/unite_platform/mobile_page/typd/zcpd";
    }
    @GetMapping("/mobile_page/haocai/mendian_hc")
    public String zcpd_hc(@RequestParam("StoreNO") String StoreNO,@RequestParam("StoreName") String StoreName,@RequestParam("Statue") String Statue,
    					ModelMap map) {
    	map.addAttribute("StoreNO", StoreNO);
    	map.addAttribute("StoreName", StoreName);
    	map.addAttribute("Statue", Statue);
        return "/views/unite_platform/mobile_page/typd/zcpd_HC";
    }
    @GetMapping("/mobile_page/haocai/paperno")
    public String paperno(@RequestParam("PaperNO") String PaperNO,@RequestParam("StoreNO") String StoreNO,@RequestParam("StoreName") String StoreName,@RequestParam("Statue") String Statue,ModelMap map) {
    	map.addAttribute("PaperNO", PaperNO);
    	map.addAttribute("StoreNO", StoreNO);
      	map.addAttribute("StoreName", StoreName);
    	map.addAttribute("Statue", Statue);
        return "/views/unite_platform/mobile_page/typd/zcpd1";
    }
    @GetMapping("/mobile_page/haocai/paperno_hc")
    public String paperno_hc(@RequestParam("PaperNO") String PaperNO,@RequestParam("StoreNO") String StoreNO,@RequestParam("StoreName") String StoreName,@RequestParam("Statue") String Statue,ModelMap map) {
    	map.addAttribute("PaperNO", PaperNO);
    	map.addAttribute("StoreNO", StoreNO);
      	map.addAttribute("StoreName", StoreName);
    	map.addAttribute("Statue", Statue);
        return "/views/unite_platform/mobile_page/typd/zcpd1_HC";
    }
    @GetMapping("/mobile_page/haocai/paperno2")
    public String paperno2(@RequestParam("PaperNO") String PaperNO,@RequestParam("StoreNO") String StoreNO,@RequestParam("StoreName") String StoreName,@RequestParam("Statue") String Statue,ModelMap map) {
    	map.addAttribute("PaperNO", PaperNO);
    	map.addAttribute("StoreNO", StoreNO);
      	map.addAttribute("StoreName", StoreName);
    	map.addAttribute("Statue", Statue);
        return "/views/unite_platform/mobile_page/typd/zcpd2";
    }
    @GetMapping("/mobile_page/haocai/paperno2_hc")
    public String paperno2_hc(@RequestParam("PaperNO") String PaperNO,@RequestParam("StoreNO") String StoreNO,@RequestParam("StoreName") String StoreName,@RequestParam("Statue") String Statue,ModelMap map) {
    	map.addAttribute("PaperNO", PaperNO);
    	map.addAttribute("StoreNO", StoreNO);
      	map.addAttribute("StoreName", StoreName);
    	map.addAttribute("Statue", Statue);
        return "/views/unite_platform/mobile_page/typd/zcpd2_HC";
    }
    @GetMapping("/mobile_page/haocai/jh_mendianpandian")
    public String jh_mendianpandian(@RequestParam("BillNO") String BillNO,@RequestParam("StoreNO") String StoreNO,@RequestParam("StoreName") String StoreName,@RequestParam("Statue") String Statue,@RequestParam("nw") String nw,ModelMap map){
    	map.addAttribute("BillNO", BillNO);
    	map.addAttribute("StoreNO", StoreNO);
    	map.addAttribute("StoreName", StoreName);
       	map.addAttribute("Statue", Statue);
     	map.addAttribute("nw", nw);
        return "/views/unite_platform/mobile_page/typd/jh_mendianpandian";
    }
    @GetMapping("/mobile_page/haocai/jh_mendianpandian_hc")
    public String jh_mendianpandian_hc(@RequestParam("BillNO") String BillNO,@RequestParam("StoreNO") String StoreNO,@RequestParam("StoreName") String StoreName,@RequestParam("Statue") String Statue,@RequestParam("nw") String nw,ModelMap map){
    	map.addAttribute("BillNO", BillNO);
    	map.addAttribute("StoreNO", StoreNO);
    	map.addAttribute("StoreName", StoreName);
       	map.addAttribute("Statue", Statue);
     	map.addAttribute("nw", nw);
        return "/views/unite_platform/mobile_page/typd/jh_mendianpandian_HC";
    }
    @GetMapping("/mobile_page/haocai/jh_mendianpandian1")
    public String jh_mendianpandian1(@RequestParam("PaperNO") String PaperNO,@RequestParam("StoreNO") String StoreNO,@RequestParam("StoreName") String StoreName,@RequestParam("Statue") String Statue,ModelMap map){
    	map.addAttribute("PaperNO", PaperNO);
       	map.addAttribute("StoreNO", StoreNO);
       	map.addAttribute("StoreName", StoreName);
       	map.addAttribute("Statue", Statue);
        return "/views/unite_platform/mobile_page/typd/jh_mendianpandian1";
    }
    @GetMapping("/mobile_page/haocai/jh_mendianpandian1_hc")
    public String jh_mendianpandian1_hc(@RequestParam("PaperNO") String PaperNO,@RequestParam("StoreNO") String StoreNO,@RequestParam("StoreName") String StoreName,@RequestParam("Statue") String Statue,ModelMap map){
    	map.addAttribute("PaperNO", PaperNO);
       	map.addAttribute("StoreNO", StoreNO);
       	map.addAttribute("StoreName", StoreName);
       	map.addAttribute("Statue", Statue);
        return "/views/unite_platform/mobile_page/typd/jh_mendianpandian1_HC";
    }
	/**
	 * 盘点保存
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="盘点保存")
	@PostMapping("/typd/pdsave")
	@ResponseBody
	public JSONObject pdsave(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.pdsave(json, response, session);
		return response;
	}
	/**
	 * 盘点保存
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="盘点保存")
	@PostMapping("/typd/pdsave_hc")
	@ResponseBody
	public JSONObject pdsave_hc(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.pdsave_hc(json, response, session);
		return response;
	}
	
	/**
	 * 盘点查询
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="盘点查询")
	@PostMapping("/typd/pandianchaxvn")
	@ResponseBody
	public JSONObject pandianchaxvn(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.pandianchaxvn(json, response, session);
		return response;
	}
	/**
	 * 盘点查询
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="盘点查询")
	@PostMapping("/typd/pandianchaxvn_hc")
	@ResponseBody
	public JSONObject pandianchaxvn_hc(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.pandianchaxvn_hc(json, response, session);
		return response;
	}
	 @GetMapping("/mobile_page/haocai/mdsearch")
	    public String mdsearch(@RequestParam("PaperNO") String PaperNO,ModelMap map) {
	    	map.addAttribute("PaperNO", PaperNO);
	        return "/views/unite_platform/mobile_page/typd/mdsearch";
	  }
	 @GetMapping("/mobile_page/haocai/mdsearch_hc")
	    public String mdsearch_hc(@RequestParam("PaperNO") String PaperNO,ModelMap map) {
	    	map.addAttribute("PaperNO", PaperNO);
	        return "/views/unite_platform/mobile_page/typd/mdsearch_HC";
	  }
	/**
	 * 返回盘点员
	 */
	@PostMapping("/typd/getusername")
	@ResponseBody
	public JSONObject getusername(@RequestBody JSONObject json){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.getusername(json, response);
		return response;
	}
	/**
	 * 盘点查询
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="库存查询")
	@PostMapping("/typd/StockSelect")
	@ResponseBody
	public JSONObject StockSelect(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = haocaiSelectService.StockSelect(json, response, session);
		return response;
	}
}
